package com.l2jserver.gameserver.network.serverpackets;

import com.l2jserver.gameserver.model.TradeItem;

/**
 * @author daemon
 */

public class TradeInventoryUpdate extends L2GameServerPacket
{
	private final TradeItem _item;
	private final long _amount;
	
	public TradeInventoryUpdate(TradeItem item, long amount)
	{
		_item = item;
		_amount = amount;
	}
	
	@Override
	protected final void writeImpl()
	{
		writeC(0x81);
		writeH(1);
		writeH((_amount > 0) && _item.getItem().isStackable() ? 3 : 2);
		writeH(_item.getItem().getType1());
		writeD(_item.getObjectId());
		writeD(_item.getItem().getItemId());
		writeQ(_amount);
		writeH(_item.getItem().getType2());
		writeH(_item.getCustomType1());
		writeD(_item.getItem().getBodyPart());
		writeH(_item.getEnchant());
		writeH(0x00);
		writeH(_item.getCustomType2());
		
		writeH(_item.getAttackElementType());
		writeH(_item.getAttackElementPower());
		for (byte i = 0; i < 6; i++)
		{
			writeH(_item.getElementDefAttr(i));
		}
		
		writeH(_item.getEnchantOptions()[0]);
		writeH(_item.getEnchantOptions()[1]);
		writeH(_item.getEnchantOptions()[2]);
	}
}